﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class MouseOver : MonoBehaviour
{
    public GameObject other_bg;
    public LevelSelect canv;
    public int[] sum = new int[6]; //正确的数组初始化
    private string text_star;
    private int i;

    private void Awake()
    {
        sum = canv.star_k;
        if ((transform.name =="scene-1" && sum[0] >= 0)||(transform.name == "scene-2" && sum[0] >= 4)|| (transform.name == "scene-3" && sum[0] >= 10))
        {
            i = int.Parse(transform.name.Split('-')[1]);

            //对应的图解锁对应的场景
            transform.Find("lock").gameObject.SetActive(false);
            transform.Find("unlock").gameObject.SetActive(true);
            text_star = sum[i].ToString() + transform.Find("unlock").Find("sum").GetComponent<Text>().text;
            transform.Find("unlock").Find("sum").GetComponent<Text>().text = text_star;
            //启用点击事件
            transform.GetComponent<Button>().enabled = true;
        }
    }
    
    private void OnMouseEnter()
    {
        canv.GetBackground(other_bg);
    }
}
